﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace NETCORE.TAttribute.Valide.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        [HttpPost]
        [Route("WebAPIApply")]
        public IActionResult WebAPIApply(PersonalRequest request)
        {
            PersonalRequest model = new PersonalRequest()
            {
                Id = 1,
                Name = "a",
                Sex = "leixm",
                Address = "c"
            };

            ValidationContext validationContext = new ValidationContext(model);
            List<ValidationResult> results = new List<ValidationResult>();
            bool isValid = Validator.TryValidateObject(model, validationContext, results, true);

            return Ok();
        }
    }
}

